import config from "@/config";
import http from "@/utils/request";

export default {
	upload: {
		url: `${config.API_URL}/upload`,
		name: "文件上传",
		post: async function (data, config = {}, path = "/product") {
			return await http.put(this.url + path, data, config);
		},
	},
	uploadAvatar: {
		url: `${config.API_URL}/upload` + "/avatar",
		name: "头像上传",
		post: async function (data, config = {}) {
			return await http.put(this.url, data, config);
		},
	},
	uploadFile: {
		url: `${config.API_URL}/upload` + "/attachments",
		name: "附件上传",
		post: async function (data, config = {}) {
			return await http.put(this.url, data, config);
		},
	},
	exportFile: {
		url: `${config.API_URL}/fileExport`,
		name: "导出附件",
		get: async function (data, config = {}) {
			return await http.get(this.url, data, config);
		},
	},
	importFile: {
		url: `${config.API_URL}/fileImport`,
		name: "导入附件",
		post: async function (data, config = {}) {
			return await http.post(this.url, data, config);
		},
	},
	file: {
		menu: {
			url: `${config.API_URL}/file/menu`,
			name: "获取文件分类",
			get: async function () {
				return await http.get(this.url);
			},
		},
		list: {
			url: `${config.API_URL}/file/list`,
			name: "获取文件列表",
			get: async function (params) {
				return await http.get(this.url, params);
			},
		},
	},
	getI18nData: {
		url: `${config.API_URL}/i18n/`,
		get: async function (locale, config = {}) {
			return await http.get(this.url + locale, {}, config);
		},
	},
	userSelect: {
		url: `${config.API_URL}/user-select-option/bySelectId/`,
	},
	// 获取附件列表
	associationFiles: {
		url: `${config.API_URL}/` + "associationFiles",
		name: "获取文件",
		get: async function (params, config = {}) {
			return await http.get(this.url, params, config);
		},
	},
	// 通过文件id获取预览url
	preview: {
		url: `${config.API_URL}/upload/preview/`,
		name: "通过文件id获取预览url",
		get: async function (params) {
			return await http.get(`${this.url}${params.bizId}`);
		},
	},
	getByObjCode: {
		url: `${config.API_URL}/crm/cost-category/getByObjCode/`,
		name: "根据对象code获取自定义费用",
		get: async function (objCode) {
			return await http.get(`${this.url}${objCode}`);
		},
	},
	getByObjCodeList: {
		url: `${config.API_URL}/crm/cost-category/getByObjCode/list`,
		name: "根据对象code获取自定义费用",
		get: async function (objCode) {
			return await http.get(`${this.url}${objCode}`);
		},
	}
};
